package com.sgb.kjwl.view.ui.adapter.enterprise;

import android.content.Context;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.swgk.core.view.entity.TalentEntity;
import com.sgb.kjwl.view.ui.activity.enterprise.TalentDetailActivity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class TalentAdapter extends BaseRecycleAdapter<TalentEntity> {

    Context context;

    public TalentAdapter(Context context, List<TalentEntity> datas) {
        super(context, R.layout.item_excellent_person, datas);
        this.context = context;
    }

    @Override
    public void convert(ItemViewHolder holder, TalentEntity talentEntity) {
        holder.setBinding(BR.viewModel, talentEntity);

        holder.getItem().setOnClickListener(view ->
//                showDialog(talentEntity)
                        TalentDetailActivity.start(context,talentEntity)
        );

    }

//    private void showDialog(TalentEntity talentEntity) {
//        LayoutInflater inflater = LayoutInflater.from(context);
//        View layout = inflater.inflate(R.layout.popwindow_talent, null);
//        AlertDialog dialog;
//        AlertDialog.Builder builder = new AlertDialog.Builder(context);
//        builder.setView(layout);
//        builder.setCancelable(true);
//        dialog = builder.show();
//        dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
//
//        DisplayMetrics dm = new DisplayMetrics();
//        //获取屏幕信息
//        dm = context.getResources().getDisplayMetrics();
//        int screenWidth = dm.widthPixels;
//        int screenHeigh = dm.heightPixels;
//        CardView cv = dialog.findViewById(R.id.cv_dialog);
//        LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) cv.getLayoutParams(); //取控件textView当前的布局参数
//        linearParams.width = screenWidth - 100;//
//        linearParams.height = screenHeigh / 3;//
//        cv.setLayoutParams(linearParams);
//
//        RoundImageView rivHead = dialog.findViewById(R.id.logo_view_dialog);
//        TextView titleView = dialog.findViewById(R.id.title_view);
//        TextView age = dialog.findViewById(R.id.tv_age);
//        TextView experience = dialog.findViewById(R.id.tv_experience);
//        TextView position = dialog.findViewById(R.id.tv_position);
//        TextView goodWork = dialog.findViewById(R.id.tv_good_work);
//        TextView person = dialog.findViewById(R.id.tv_person);
//        if (talentEntity != null) {
//            Glide.with(context).load(talentEntity.getHeadImg()).into(rivHead);
//            titleView.setText(talentEntity.getName());
//            age.setText(talentEntity.getAge() + "岁");
//            experience.setText(talentEntity.getExperience() + "年");
//            position.setText(talentEntity.getPosition());
//            goodWork.setText(talentEntity.getBusiness());
//            person.setText( talentEntity.getProfile());
//        }
//        dialog.findViewById(R.id.iv_cancel).setOnClickListener(v -> dialog.dismiss());
//    }

}
